#ifndef __GDLINK_H__
#define __GDLINK_H__


/*** Public header file  */
#include "cc_type.h"

/*** define   */
    
#ifndef CC_LIST_ENTRY
#define CC_LIST_ENTRY(pNode, type, member) \
    ((type *)((char *)pNode - ((long)&((type *)0)->member)))
	
#endif
	
/*** struct define  */

typedef struct CC_GDLink_MgmHead tGDLHead;
typedef int (*tpCmpRule)(void* InPara,void* pNodeObj);


struct CC_GDLink_MgmHead{
	tDLNode* 	pHead;
	tpCmpRule 	pObjCmp;		// 实现 对象的 >=< 比较操作  
	uint16_t 	NumCnt;	  		// 统计链表的总数量;
	uint8_t  	Id;				// N-链表的ID
	uint8_t  	Res;			// DLinkType // 线性链表 or 环形链表
	//Ex
	const uint8_t* 	pName;			// 
};

#define CFG_GDLINK_MODE              		  
#ifdef  CFG_GDLINK_MODE

extern tGDLHead* GDLink_SCreateByName(const uint8_t* pName,tpCmpRule pObjCmp);
extern int GDLink_ShowCBF(uint8_t* pStr,tGDLHead* pObj,int (*pFunc)(tDLNode* pNode));
extern int GDLink_SetCmp(tGDLHead* pObj,tpCmpRule pCmp);

extern int GDLink_AddAfter(tGDLHead* pObj,tDLNode* pNowNode,tDLNode* pAddNode);
extern int GDLink_AddBefore(tGDLHead* pObj,tDLNode* pNowNode,tDLNode* pAddNode);
// 
extern int GDLink_AddToHead(tGDLHead* pObj,tDLNode* pAddNode);
extern int GDLink_AddToTail(tGDLHead* pObj,tDLNode* pAddNode);
extern tDLNode* GDLink_DelByNodePtr(tGDLHead* pObj,tDLNode* pDelNode);

extern tDLNode* GDLink_Search(tGDLHead* pObj,void* pInPara);
extern int GDLink_Notify(tGDLHead* pObj,int (*pFunc)(tDLNode* pNode)); // 遍历执行框架
// extern tDLNode* GDLink_Check_IsDLinkNode(tGDLHead* pObj,tDLNode* pCheckNode);

// extern int GDLink_SortAdd(tGDLHead* pObj,tDLNode* pAddNode);	//用于priority queue

#endif

// #define CFG_UT_GDLINK              	  
#ifdef CFG_UT_GDLINK
extern int UT_GDLink(void);
#endif

#endif 
